import api from "@/api/index.js"

export function selectCommonwordWords() {
    return api.request({
        method: 'post',
        url: '/select/commonword/words',
    })
}

export function updateCommonwordWords(data) {
    data = data.map(item => {
        if (!item.includes("''")) {
            item = item.replace(/'/g, "''")
        }
        return item
    })
    return api.request({
        method: 'post',
        url: '/update/commonword/words',
        data
    })
}

export function insertCommonSentence(data) {
    for (let key of Object.keys(data)) {
        let value = data[key]
        if (!value.includes("''")) {
            value = value.replace(/'/g, "''")
        }
        data[key] = value
    }
    return api.request({
        method: 'post',
        url: '/insert/commonsentence',
        data
    })
}

export function selectCommonSentence() {
    return api.request({
        method: 'post',
        url: '/select/commonsentence',
    })
}

export function deleteCommonSentence(data) {
    return api.request({
        method: 'post',
        url: '/delete/commonsentence',
        data
    })
}

export function updateCommonSentence(data) {
    return api.request({
        method: 'post',
        url: '/update/commonsentence',
        data
    })
}

export function updateSpeak(data) {
    return api.request({
        method: 'post',
        url: '/update/speak',
        data
    })
}

export function selectSpeak() {
    return api.request({
        method: 'post',
        url: '/select/speak',
    })
}